import 'package:flutter/material.dart';
import 'package:tuya_home_sdk_flutter/tuya_home_sdk_flutter.dart';

@immutable
class DeviceDiscoveryState {
  final List<ThingSmartDeviceModel> devices;
  final bool isSearching;
  final String? error;

  const DeviceDiscoveryState({
    this.devices = const [],
    this.isSearching = false,
    this.error,
  });

  DeviceDiscoveryState copyWith({
    List<ThingSmartDeviceModel>? devices,
    bool? isSearching,
    String? error,
  }) {
    return DeviceDiscoveryState(
      devices: devices ?? this.devices,
      isSearching: isSearching ?? this.isSearching,
      error: error ?? this.error,
    );
  }

  @override
  bool operator ==(Object other) {
    return identical(this, other) ||
        other is DeviceDiscoveryState &&
            runtimeType == other.runtimeType &&
            devices == other.devices &&
            isSearching == other.isSearching &&
            error == other.error;
  }

  @override
  int get hashCode => devices.hashCode ^ isSearching.hashCode ^ error.hashCode;
}
